package com.sneakxy.cloudbase.platform.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import com.sneakxy.mybatis.commons.repository.query.domain.Criteria;

/**
 * 业务接口基类
 * @author 潜行的青衣
 * @see
 */
public interface IBaseService<T, I extends Serializable> {
	
	public static final String DATE_TIME_FORMATTER = "yyyy-MM-dd HH:mm:ss";  
	
	public String getTableName(String id, int size);
	
	public String getTableName(long id, int size);
	
	public String getTableName(int id, int size);

	public Iterable<T> findAll();
	
	public Iterable<T> findAll(String tableName);
	
	public Iterable<T> findAll(Sort sort);
	
	public Iterable<T> findAll(String tableName, Sort sort);
	
	public Iterable<T> findAll(Iterable<I> ids);
	
	public Page<T> findAll(Pageable pageable);
	
	public Page<T> findAll(String tableName, Pageable pageable);
	
	public T findOne(I id);
	
	public T findOne(I id, String tableName);
	
	public boolean exists(I id);
	
	public boolean exists(I id, String tableName);
	
	public T findOne(Criteria<T> criteria);
	
	public T findOne(Criteria<T> criteria, String tableName);
	
	public List<T> findAll(Criteria<T> criteria);
	
	public List<T> findAll(Criteria<T> criteria, String tableName);
	
	public Page<T> findAll(Criteria<T> criteria, Pageable pageable);
	
	public Page<T> findAll(Criteria<T> criteria, String tableName, Pageable pageable);
	
	public List<T> findAll(Criteria<T> criteria, Sort sort);
	
	public List<T> findAll(Criteria<T> criteria, String tableName, Sort sort);
	
	public <S extends T> S save(S entity);
	
	public <S extends T> S save(S entity, String tableName);
	
	public <S extends T> Iterable<S> save(Iterable<S> entities);
	
	public <S extends T> S update(S entity, Criteria<S> criteria, String tableName);
	
	public <S extends T> S update(S entity, Criteria<S> criteria);
	
	public void delete(I id);
	
	public void delete(I id, String tableName);
	
	public void delete(T entity);
	
	public void delete(Iterable<? extends T> entities);
	
	public void delete(Criteria<T> criteria, String tableName);
	
	public void delete(Criteria<T> criteria);
	
	public void deleteAll();
	
	public void deleteAll(String tableName);
	
	public long count(Criteria<T> criteria);
	
	public long count(Criteria<T> criteria, String tableName);
	
	public long count();
	
	public long count(String tableName);
	
}
